package cn.tedu.api;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import sun.util.resources.cldr.sq.CalendarData_sq_AL;

import javax.sound.sampled.Clip;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

/**
 * Date：2021年10月
 * Author：程Sir
 * Name： JavaSE-API
 * Content:
 *
 *      Calendar也是java.util包下的，但是是一个抽象类，通过调用工厂方法来完成实例化：Calender.getInstence();
 *      int get(int field);
 *      void set(int field,int value);
 */
public class CalendarDemo {
    public static void main(String[] args) {
        //创建当前时间对象
        Calendar c = Calendar.getInstance();
        int y = c.get(Calendar.YEAR);
        int m = c.get(Calendar.MONTH) + 1;// 月份是0~11
        int d = c.get(Calendar.DAY_OF_MONTH);// 1-7 分别表示：日一二三四五六

        int w = c.get(Calendar.DAY_OF_WEEK);
        int h = c.get(Calendar.HOUR_OF_DAY);
        int mm = c.get(Calendar.MINUTE);
        int s = c.get(Calendar.SECOND);

        System.out.println(y+"年"+m+"月"+d+"日 "+h+ "时"+mm+"分"+s+"秒" +"，星期"+w);

        Calendar c1 = Calendar.getInstance();

        //设置时间分量
        c1.set(Calendar.YEAR,2008);
        c1.set(Calendar.MONTH,9); // 0~11
        c1.set(Calendar.DAY_OF_MONTH,10);
//        c1.set(Calendar.DAY_OF_WEEK,5); // 星期四
        c1.set(Calendar.HOUR_OF_DAY,10);
        c1.set(Calendar.MINUTE,10);
        c1.set(Calendar.SECOND,10);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");

        System.out.println(simpleDateFormat.format(c1.getTime()));


    }
}
